﻿using System;
using UnityEngine;
using UnityEngine.UI;

namespace WoogiUI
{
    [RequireComponent(typeof(Toggle))]
    public class WoogiToggle : WoogiGameObject
    {
        Action<bool,GameObject> click;
        public void Awake()
        {
            toggle.onValueChanged.AddListener(OnClick);
        }

        private void OnClick(bool arg0)
        {
            if (click != null)
            {
                click(arg0,gameObject);
                //PlaySound.PlaySoundClickButton();
            }
        }

        public Toggle toggle
        {
            get { return GetComponent<Toggle>(); }
        }

        public void SetEvent(Action<bool,GameObject> callbackEvent)
        {
            click = callbackEvent;
        }
    }
}
